﻿using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Text;
using System.Web.Script.Serialization;

namespace Agile {
    public class 节假日 {

        public static void 获取节假日() {
            string formatString = "http://timor.tech/api/holiday/year";
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(formatString);
            request.Method = "GET";
            request.ContentType = "text/html;charset=UTF-8";
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            Stream myResponseStream = response.GetResponseStream();
            StreamReader myStreamReader = new StreamReader(myResponseStream,Encoding.GetEncoding("utf-8"));
            string retString = myStreamReader.ReadToEnd();
            myStreamReader.Close();
            myResponseStream.Close();
            if(retString.IndexOf("7200") > 0) {
                JavaScriptSerializer js = new JavaScriptSerializer();   //实例化一个能够序列化数据的类
                var list = js.Deserialize<MyClass>(retString);
            }
        }
    }
    public class MyClass {
        public int code { get; set; }
        public List<YearHoliday> holiday { get; set; }
    }
    public class YearHoliday {
        public bool holiday { get; set; }
        public string date { get; set; }
        public string name { get; set; }
        public string target { get; set; }
        public int wage { get; set; }
        public string after { get; set; }
        public string rest { get; set; }
    }
}
